package com.yida.gwj.api.service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.constant.ServiceNameConstants;
import com.yida.common.core.domain.R;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.gwj.api.domain.GwjFinanceAccountDetail;
import com.yida.gwj.api.domain.GwjFinanceAccountMain;
import com.yida.gwj.api.domain.GwjFinanceBank;
import com.yida.gwj.api.domain.GwjFinanceMoney;
import com.yida.gwj.api.domain.request.RemoteAccountDetailForRateRequest;
import com.yida.gwj.api.domain.request.RemoteGwjFinanceAccountDetailRequest;
import com.yida.gwj.api.domain.request.RemoteGwjFinanceAccountMainRequest;
import com.yida.gwj.api.factory.RemoteGwjConfigFallbackFactory;

/**
 * 20230213 公维金财务服务
 *
 * @author lqq
 */
@FeignClient(contextId = "remoteGwjFinanceService", value = ServiceNameConstants.GWJ_FINANCE_SERVICE, fallbackFactory = RemoteGwjConfigFallbackFactory.class)
public interface RemoteGwjFinanceService {

    /**
     * 新增银行分类帐信息
     *
     * @param gwjFinanceAccountDetail 银行分类账
     * @param source /
     * @return /
     */
    @PostMapping("/accountDetail/inner")
    R<Integer> addGwjFinanceAccountDetail(@RequestBody GwjFinanceAccountDetail gwjFinanceAccountDetail, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 批量新增银行分类帐信息
     *
     * @param accountDetails 银行分类账集合
     * @param source /
     * @return /
     */
    @PostMapping("/accountDetail/innerBatch")
    R<Integer> addBatchGwjFinanceAccountDetail(@RequestBody ArrayList<GwjFinanceAccountDetail> accountDetails, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改银行分类帐信息
     *
     * @param gwjFinanceAccountDetail 银行分类账
     * @param source /
     * @return /
     */
    @PutMapping("/accountDetail/inner")
    R<Integer> updateGwjFinanceAccountDetail(@RequestBody GwjFinanceAccountDetail gwjFinanceAccountDetail, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据业务ID删除分类帐信息
     *
     * @param bizId 业务ID
     * @param source /
     * @return /
     */
    @DeleteMapping("/accountDetail/inner/{bizId}")
    R<Integer> deleteGwjFinanceAccountDetailByBizId(@PathVariable("bizId") Long bizId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据业务ID查询类帐信息
     *
     * @param bizId 业务ID
     * @param source /
     * @return /
     */
    @GetMapping("/accountDetail/inner/list/{bizId}")
    R<List<GwjFinanceAccountDetail>> selectGwjFinanceAccountDetailListByBizId(@PathVariable("bizId") Long bizId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询分账流水（连表 总账流水）
     *
     * @param gwjFinanceAccountDetail 总账流水
     * @param source /
     * @return /
     */
    @PostMapping("/accountDetail/inner/list")
    R<List<GwjFinanceAccountDetail>> selectGwjFinanceAccountDetailList(@RequestBody GwjFinanceAccountDetail gwjFinanceAccountDetail, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 新增总账流水
     *
     * @param gwjFinanceAccountMain 总账流水
     * @param source /
     * @return /
     */
    @PostMapping("/accountMain/inner")
    R<Integer> insertGwjFinanceAccountMain(@RequestBody GwjFinanceAccountMain gwjFinanceAccountMain, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改总账流水
     *
     * @param gwjFinanceAccountMain 总账流水
     * @param source /
     * @return /
     */
    @PutMapping("/accountMain/inner")
    R<Integer> updateGwjFinanceAccountMain(@RequestBody GwjFinanceAccountMain gwjFinanceAccountMain, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据业务ID删除总账流水
     *
     * @param bizId 业务ID
     * @param source /
     * @return /
     */
    @DeleteMapping("/accountMain/inner/{bizId}")
    R<Integer> deleteGwjFinanceAccountMainByBizId(@PathVariable("bizId") Long bizId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据业务ID查询总账流水
     *
     * @param bizId 业务ID
     * @param source /
     * @return /
     */
    @GetMapping("/accountMain/inner/{bizId}")
    R<GwjFinanceAccountMain> selectGwjFinanceAccountMainByBizId(@PathVariable("bizId") Long bizId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询总账流水列表
     *
     * @param gwjFinanceAccountMain 总账流水
     * @param source /
     * @return /
     */
    @PostMapping("/accountMain/inner/list")
    R<List<GwjFinanceAccountMain>> selectGwjFinanceAccountMainList(@RequestBody GwjFinanceAccountMain gwjFinanceAccountMain, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询总账流水列表
     *
     * @param mainRequest 总账流水
     * @param source /
     * @return /
     */
    @PostMapping("/accountMain/inner/page")
    R<TableDataInfo> selectGwjFinanceAccountMainPage(@RequestBody RemoteGwjFinanceAccountMainRequest mainRequest, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过银行ID和地区ID查询银行信息详细信息
     *
     * @param bankId 银行ID
     * @param areaId 地区ID
     * @param source /
     * @return /
     */
    @GetMapping("/bank/{bankId}/{areaId}")
    R<GwjFinanceBank> selectFinanceBankByBankIdAndAreaId(@PathVariable("bankId") Long bankId, @PathVariable("areaId") Long areaId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取缴存金额收入总帐明细详细信息
     *
     * @param moneyId 明细账ID
     * @param source /
     * @return /
     */
    @GetMapping("/money/inner/{moneyId}")
    R<GwjFinanceMoney> selectFinanceMoneyByMoneyId(@PathVariable("moneyId") Long moneyId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询缴存金额收入总帐明细列表
     *
     * @param financeMoney 缴存金额收入总帐明细
     * @param source /
     * @return /
     */
    @PostMapping("/money/inner/list")
    R<List<GwjFinanceMoney>> selectFinanceMoneyList(@RequestBody GwjFinanceMoney financeMoney, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改缴存金额收入总帐明细
     *
     * @param financeMoney 缴存金额收入总帐明细
     * @param source /
     * @return /
     */
    @PutMapping("/money/inner")
    R<Integer> updateFinanceMoney(@RequestBody GwjFinanceMoney financeMoney, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 批量修改银行分类帐信息
     *
     * @param details 分类账信息明细
     * @param source
     * @return
     */
    @PostMapping("/accountDetail/innerEditBatch")
    R<Integer> updateBatchGwjFinanceAccountDetail(@RequestBody ArrayList<GwjFinanceAccountDetail> details, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 缴存金额收入总帐明细清空绑定的业务信息
     *
     * @param financeMoney 缴存金额收入总帐明细
     * @param source /
     * @return 结果
     */
    @PutMapping("/money/inner/clear")
    R<Integer> clearFinanceMoneyBizInfo(@RequestBody GwjFinanceMoney financeMoney, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 批量新增银行分类帐信息
     *
     * @param accountDetailArrayList 分类账信息明细
     * @param source
     * @return
     */
    @PostMapping("/accountDetail/innerSaveBatch")
    R<Integer> insertBatchGwjFinanceAccountDetailInner(@RequestBody ArrayList<GwjFinanceAccountDetail> accountDetailArrayList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询分账列表
     *
     * @param detailRequest
     * @param source
     * @return
     */
    @PostMapping("/accountDetail/getGwjFinanceAccountDetailList")
    R<List<GwjFinanceAccountDetail>> getGwjFinanceAccountDetailList(@RequestBody RemoteGwjFinanceAccountDetailRequest detailRequest, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询分账列表
     *
     * @param detailRequest
     * @param source
     * @return
     */
    @PostMapping("/accountDetail/getGwjFinanceAccountDetailPage")
    R<TableDataInfo> getGwjFinanceAccountDetailPage(@RequestBody RemoteGwjFinanceAccountDetailRequest detailRequest, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询分账列表 用于计息
     *
     * @param request
     * @param source
     * @return
     */
    @PostMapping("/accountDetail/getListForRate")
    R<List<GwjFinanceAccountDetail>> getListForRate(@RequestBody RemoteAccountDetailForRateRequest request, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询总账流水
     *
     * @param financeAccountMain
     * @param source
     * @return {@link R}<{@link GwjFinanceAccountMain}>
     */
    @PostMapping("/accountMain/getGwjFinanceAccountMain")
    R<GwjFinanceAccountMain> getGwjFinanceAccountMain(@RequestBody GwjFinanceAccountMain financeAccountMain, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 删除总账流水
     *
     * @param financeAccountMain
     * @param source
     * @return {@link R}<{@link Integer}>
     */
    @PostMapping("/accountMain/deleteGwjFinanceAccountMain")
    R<Integer> deleteGwjFinanceAccountMain(@RequestBody GwjFinanceAccountMain financeAccountMain, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 删除分类账流水
     *
     * @param financeAccountDetail
     * @param source
     * @return {@link R}<{@link Integer}>
     */
    @PostMapping("/accountDetail/deleteGwjFinanceAccountDetail")
    R<Integer> deleteGwjFinanceAccountDetail(@RequestBody GwjFinanceAccountDetail financeAccountDetail, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询银行Map
     * 
     * @param areaId 地区ID
     * @param source
     * @return
     */
    @GetMapping("/bank/selectFinanceBankMapInner/{areaId}")
    R<Map<Long, String>> selectFinanceBankMapInner(@PathVariable("areaId") Long areaId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 获取分类账统计信息
     * 
     * @param financeAccountDetail
     * @return
     */
    @PostMapping("/accountDetail/selectGwjFinanceAccountDetailStatistics")
    R<Map<String, BigDecimal>> selectGwjFinanceAccountDetailStatistics(@RequestBody GwjFinanceAccountDetail financeAccountDetail, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 修改总账流水
     *
     * @param gwjFinanceAccountMain 总账流水
     * @param source /
     * @return /
     */
    @PutMapping("/accountMain/inner/mainInfo")
    R<Integer> updateGwjFinanceAccountMainInfo(@RequestBody GwjFinanceAccountMain gwjFinanceAccountMain, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
